package com.gupao.javap6.schemadesign;

import com.gupao.javap6.schemadesign.factory.InPaymentFactory;
import com.gupao.javap6.schemadesign.factory.OutPaymentFactory;
import com.gupao.javap6.schemadesign.factory.PaymentFactory;
import com.gupao.javap6.schemadesign.service.AlipayService;
import com.gupao.javap6.schemadesign.service.ApplePayService;
import com.gupao.javap6.schemadesign.service.UnionPayService;
import com.gupao.javap6.schemadesign.service.WechatPayService;

import java.io.Serializable;

/**
 * TODO
 *
 * @author withinfly(45度C)
 * @date 2020/2/24 22:44
 */
public class TestBusiness implements Serializable {
    private static final long serialVersionUID = 1L;

    public static void main(String[] args) {
        String orderNo = String.valueOf(System.currentTimeMillis());
        double orderAmount = 10189.20D;
        String currency = "美元";
        String body = "咕泡Java P6 架构师课程";

        InPaymentFactory inPaymentFactory = PaymentFactory.getInPaymentFactory();
        OutPaymentFactory outPaymentFactory = PaymentFactory.getOutPaymentFactory();

        AlipayService alipayService = inPaymentFactory.creating(AlipayService.class);
        alipayService.pay(orderNo, orderAmount, body);

        WechatPayService wechatPayService = inPaymentFactory.creating(WechatPayService.class);
        wechatPayService.pay(orderNo, orderAmount, body);

        UnionPayService unionPayService = inPaymentFactory.creating(UnionPayService.class);
        unionPayService.pay(orderNo, orderAmount, body);

        ApplePayService applePayService = outPaymentFactory.creating(ApplePayService.class);
        applePayService.pay(orderNo, orderAmount, body, currency);

    }

}
